package com.liyunc.demo.comp.common.data.fetch;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author liyuncong
 * @version 1.0
 * @file PageableResult
 * @brief PageableResult
 * @details PageableResult
 * @date 2022-04-28
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                        NAME               DESCRIPTION
 * 2022-04-28                      liyuncong          Created
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class PageableResult {
    // size of each page
    private int size;
    // current page number
    private int index;
    // number of current pages
    private int current;
    private Long totalRecords;
    private Integer totalPages;

    public static PageableResult of(
        final int pageSize,
        final int pageIndex,
        final int currentPageRecords,
        final Long totalRecords,
        final int totalPages
    ) {
        return new PageableResult(
            pageSize,
            pageIndex,
            currentPageRecords,
            totalRecords,
            totalPages);
    }
}
